<template>
    <div class="salon">
        <search-box class="search-view"/>
        <swiper :options="swiperOptions" :auto="2000" :height="165"/>
        <think-list :list="dataList" type="2" @onclick="handleItemClick"/>
    </div>
</template>
<style lang="less" scoped>
    @import '../../style/variable';
    .salon {
        
    }
</style>
<script>
    import { Swipe, SwipeItem } from 'vant';
    import { think as API } from 'api';
    import T from 'utils/T';
    export default {
        components: {
            [Swipe.name]: Swipe,
            [SwipeItem.name]: SwipeItem,
        },
        data() {
            return {
                swiperOptions: [
                    {
                        src: 'https://img.yzcdn.cn/public_files/2017/10/24/e5a5a02309a41f9f5def56684808d9ae.jpeg',
                        to: '/same'
                    },
                    'https://img.yzcdn.cn/public_files/2017/10/24/1791ba14088f9c2be8c610d0a6cc0f93.jpeg'
                ],
                dataList: []
            }
        },
        created(){
            this.requestData();
        },
        methods: {
            handleItemClick(id) {
                this.$router.push({
                    path: '/think/salonDetail',
                    query: { id }
                });
            },
            requestData(){
                let params = {
                    type: 2
                };
                this.$axios.get(API.THINK_TANK, { params }).then((result)=>{
                    let resultData = result.data.list;
                    this.dataList = resultData.map((item, key) => {
                        return {
                            id: item.id,
                            title: item.annTitle || '无数据',
                            name: item.author || '无数据',
                            address: item.holdLocation || '无数据',
                            date: `${T.formatDate(item.holdTime)}-${T.formatDate(item.holdTimeEnd)}`,
                            state: '报名中',
                            logoImg: item.picPath,
                        }
                    });
                    console.log('resultData', resultData);
                })
            },
        }
    }
</script>